package com.ihr360.rest.webmvc;

import com.ihr360.rest.projector.EntityProjector;
import lombok.NonNull;
import org.springframework.data.rest.webmvc.PersistentEntityResource;
import org.springframework.util.Assert;


public class Ihr360ResourceAssembler  {
    private final @NonNull
    EntityProjector projector;

    public Ihr360ResourceAssembler(EntityProjector projector) {
        this.projector = projector;
    }

    public Object toResource(Object instance) {
        Assert.notNull(instance, "Entity instance must not be null!");
        return projector.project(instance);
    }

    /**
     * Returns the full object as {@link PersistentEntityResource} using the underlying {@link EntityProjector}.
     *
     * @param instance must not be {@literal null}.
     * @return
     */
    public Object toFullResource(Object instance) {

        Assert.notNull(instance, "Entity instance must not be null!");
        return projector.project(instance);
    }



}